/**
 * 입력내용 배열에 저장후 정렬처리
 */
function init(){
	array = new Array();
	cnt = 0;
	document.getElementById('btnAdd').onclick=addFunc;
	document.getElementById('btnView').onclick=viewFunc;
	document.getElementById('btnSort').onclick=sortFunc;
	document.getElementById('btnNumSort').onclick=numSortFunc;
}
function addFunc(){
	var f = document.frm;
	var d = f.data.value;
	array[cnt] = d;
	cnt++;
}
function viewFunc(){
	var f= document.frm;
	var rst = document.getElementById('resultDiv');
	
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
	
}
function sortFunc(){
	var f= document.frm;
	var rst = document.getElementById('resultDiv');
	
	array.sort();
	
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
	
}

function numSortFunc(){
	var f= document.frm;
	var rst = document.getElementById('resultDiv');
	
	array.sort(numSort);
	
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
}

function numSort(x,y){
	return Number(x)-Number(y); //오름차
	//return Number(y)-Number(x); //내림차순
}




